<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const img = new Image();
      img.src = './WechatIMG9222.jpeg'
      img.onload = function () {
        const canvas = document.createElement("canvas");
        canvas.width = 600;
        canvas.height = 600;
        document.body.appendChild(canvas);
        const ctx = canvas.getContext("2d");
        // 2000,2000,500,500 : 从2000，2000 坐标点开始 截取一个500*500的图片
        // 0,0,600,600 : 将截取的图片绘制到画布的0，0坐标点，并且缩放到600*600  ··
        ctx.drawImage(img, 2000,2000,500,500,0,0,600,600);
      };
    </script>
  </body>
</html>
